Compute transpose of a matrix